<!--$Id: db_put.so,v 11.14 2004/12/16 19:13:05 bostic Exp $-->
<!--$Id: m4.tcl,v 11.28 2004/12/16 19:13:05 bostic Exp $-->
<!--Copyright (c) 1997,2008 Oracle.  All rights reserved.-->
<!--See the file LICENSE for redistribution information.-->
<html>
<head>
<title>Berkeley DB: db put</title>
<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++">
</head>
<body bgcolor=white>
<table width="100%"><tr valign=top>
<td>
<b><i>db</i> <b>put</b></b>
</td>
<td align=right>
<a href="../api_tcl/api_tcl.html"><img src="../images/api.gif" alt="API"></a>
<a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a></td>
</tr></table>
<hr size=1 noshade>
<tt>
<b><pre>db put
	-append
	[-partial {doff dlen}]
	[-txn txnid]
	data
db put
	[-nooverwrite]
	[-partial {doff dlen}]
	[-txn txnid]
	key data
</pre></b>
<b>Description(db put)</b>
<p>The <i>db</i> <b>put</b> command stores the specified key/data pair into the
database.</p>
<p>The options are as follows:</p>
<br>
<b>-append</b><ul compact><li>Append the data item to the end of the database. For the <b>-append</b>
option to be specified, the underlying database must be a Queue or Recno
database.  The record number allocated to the record is returned on
success.</ul>
<b>-nooverwrite</b><ul compact><li>Enter the new key/data pair only if the key does not already appear in
the database.</ul>
<b>-partial {doff dlen}</b><ul compact><li><p>The <b>dlen</b> bytes starting <b>doff</b> bytes from the beginning
of the specified key's data record are replaced by the data specified
by the data and size structure elements.  If <b>dlen</b> is smaller
than the length of the supplied data, the record will grow; if
<b>dlen</b> is larger than the length of the supplied data, the record
will shrink.  If the specified bytes do not exist, the record will be
extended using nul bytes as necessary, and the <i>db</i> <b>put</b> call will succeed.
<p>It is an error to attempt a partial put using the <i>db</i> <b>put</b> command in a database
that supports duplicate records. Partial puts in databases supporting
duplicate records must be done using a <i>dbc</i> <b>put</b> command.</p>
<p>It is an error to attempt a partial put with differing <b>dlen</b> and
supplied data length values in Queue or Recno databases with fixed-length
records.</p></ul>
<b>-txn txnid</b><ul compact><li>If the operation is part of an application-specified transaction, the
<b>txnid</b> parameter is a transaction handle returned from
<i>env</i> <b>txn</b>.  If no transaction handle is specified, but the
operation occurs in a transactional
database,
the operation will be implicitly transaction protected.</ul>
<br>
<p>The <i>db</i> <b>put</b> command returns either 0 or a record number for success
(the record number is returned if the <b>-append</b> option was specified).
If an error occurs, a Berkeley DB error message is returned or a Tcl error is
thrown.</p>
<p>If the underlying database is a Queue or Recno database, then the given
key will be interpreted by Tcl as an integer.  For all other database
types, the key is interpreted by Tcl as a byte array.</p>
</tt>
<table width="100%"><tr><td><br></td><td align=right>
<a href="../api_tcl/api_tcl.html"><img src="../images/api.gif" alt="API"></a><a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a>
</td></tr></table>
<p><font size=1>Copyright (c) 1996,2008 Oracle.  All rights reserved.</font>
</body>
</html>
